%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/person-log-entries.last-ordered"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 10, 11, 39, 40, 12<br />2: PgSelectInlineApply[35]<br />3: PgSelect[9]<br />ᐳ: Access[36]<br />4: Connection[13]<br />5: ConnectionItems[15]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 13, 15, 36<br /><br />ROOT Connectionᐸ9ᐳ[13]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 36<br /><br />ROOT __Item{3}ᐸ15ᐳ[18]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 18, 36, 19<br /><br />ROOT Edge{3}[19]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 20, 38<br /><br />ROOT PgSelectSingle{4}ᐸpeopleᐳ[20]"):::bucket
    Bucket6("Bucket 6 (listItem)<br /><br />ROOT __Item{6}ᐸ30ᐳ[31]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect9[["PgSelect[9∈0] ➊<br />ᐸpeopleᐳ<br />More deps:<br />- Constantᐸ5ᐳ[39]"]]:::plan
    Object12{{"Object[12∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply35["PgSelectInlineApply[35∈0] ➊<br />More deps:<br />- Constantᐸ1ᐳ[40]"]:::plan
    Object12 & PgSelectInlineApply35 --> PgSelect9
    Access10{{"Access[10∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access10 & Access11 --> Object12
    Connection13[["Connection[13∈0] ➊<br />ᐸ9ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[39]"]]:::plan
    PgSelect9 --> Connection13
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access10
    __Value2 --> Access11
    ConnectionItems15[["ConnectionItems[15∈0] ➊"]]:::plan
    Connection13 --> ConnectionItems15
    Access36{{"Access[36∈0] ➊<br />ᐸ9.m.subqueryDetailsFor24ᐳ"}}:::plan
    PgSelect9 --> Access36
    __Item18[/"__Item[18∈3]<br />ᐸ15ᐳ"\]:::itemplan
    ConnectionItems15 ==> __Item18
    Edge19{{"Edge[19∈3]"}}:::plan
    __Item18 --> Edge19
    List37{{"List[37∈4]<br />ᐸ36,18ᐳ"}}:::plan
    Access36 & __Item18 --> List37
    PgSelectSingle20{{"PgSelectSingle[20∈4]<br />ᐸpeopleᐳ"}}:::plan
    __Item18 --> PgSelectSingle20
    Lambda38{{"Lambda[38∈4]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List37 --> Lambda38
    PgClassExpression23{{"PgClassExpression[23∈5]<br />ᐸ__people__.”person_id”ᐳ"}}:::plan
    PgSelectSingle20 --> PgClassExpression23
    PgClassExpression29{{"PgClassExpression[29∈5]<br />ᐸ__people__.”username”ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression29
    PgSelectRows30[["PgSelectRows[30∈5]"]]:::plan
    Lambda38 --> PgSelectRows30
    __Item31[/"__Item[31∈6]<br />ᐸ30ᐳ"\]:::itemplan
    PgSelectRows30 ==> __Item31
    PgSelectSingle32{{"PgSelectSingle[32∈6]<br />ᐸlog_entriesᐳ"}}:::plan
    __Item31 --> PgSelectSingle32
    PgClassExpression33{{"PgClassExpression[33∈6]<br />ᐸ__log_entries__.”text”ᐳ"}}:::plan
    PgSelectSingle32 --> PgClassExpression33
    PgClassExpression34{{"PgClassExpression[34∈6]<br />ᐸ__log_entries__.”id”ᐳ"}}:::plan
    PgClassExpression33 o--o PgClassExpression34

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect9,Access10,Access11,Object12,Connection13,ConnectionItems15,PgSelectInlineApply35,Access36 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item18,Edge19 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle20,List37,Lambda38 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression23,PgClassExpression29,PgSelectRows30 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item31,PgSelectSingle32,PgClassExpression33,PgClassExpression34 bucket6

